#include"list.h"
#include<iostream>
#include<cstring>

void PrintFunction(Item& a)
{
    std::cout << "The title is: " << a.title << ", and rating is: " << a.rating <<std::endl;
}

List::List()
{
    number = 0;
}

bool List::add(Item& a)
{
    if ( number <= MAX)
    {
        ++number;
        strcpy(this->item[number - 1].title,a.title);
        this->item[number - 1].rating = a.rating;
        return true;
    }
    else
    return false;
}

bool List::isempty()
{
    return number == MAX;
}

bool List::isfull()
{
    return number == 0;
}

void List::visit(void (*pf) (Item&))
{
    for ( int i = 0; i < number; ++i)
    {
        pf(item[i]);
    }
}